import os

from twisted.application import service, internet
from twisted.python import util
from twisted.internet import reactor
from twisted.web import static
from nevow import athena, loaders, tags
from nevow import appserver

import stickies
from stickies import widgets
from stickies.templates import template_dir

static_dir = util.sibpath(stickies.__file__, os.path.join("static"))
static_resource = static.File(static_dir)


class StickiesPage(athena.LivePage):
    #docFactory = loaders.stan(T.html[
    #        T.head(render=T.directive('liveglue')),
    #        T.body(render=T.directive('myElement'))])
    
    docFactory = loaders.xmlfile(templateDir=template_dir,
                                 template="stickies.html")

    def render_myElement(self, ctx, data):
        f = widgets.board()
        # print "Creating a board element..."
        f.setFragmentParent(self)
        # print "board element page:",f.page
        return ctx.tag[f]

    def child_(self, ctx):
        return StickiesPage()

    def child_static(self, ctx):
        return static_resource
